package it.polimi.digitalstate.manager;

import it.polimi.digitalstate.dto.CitizenDTO;
import it.polimi.digitalstate.dto.JoinVoteDTO;
import it.polimi.digitalstate.dto.JoinrequestDTO;
import it.polimi.digitalstate.dto.MembershipDTO;
import it.polimi.digitalstate.dto.PartyDTO;

import javax.ejb.Local;

import managerexception.CannotSendJoinRequest;
import managerexception.CannotSendJoinVote;
import managerexception.CannotSubmitMembership;


@Local
public interface MembershipManagerLocal {
	/**
	 * This method retrieve the Joinrequest submitted by the given citizen
	 * @param citizen
	 * @return a join request
	 */
	public JoinrequestDTO getMembershipRequest(CitizenDTO citizen);
	/**
	 * This method return true if the given citizen had apply a membership request and this membership request has still in process
	 * @param citizen
	 * @return true if there is a membership request still to process for the given citizen
	 */
	public JoinrequestDTO getMembershipRequest(int id);
	
	
    public boolean isMembershipRequester(CitizenDTO citizen);
    /**
	 * Submit the request. From the web tier, if there are the right condition, the user can apply a membership request.
	 * @param membershiprequest
     * @throws CannotSendJoinRequest 
	 */
    public void submitRequest(JoinrequestDTO membershiprequest) throws CannotSendJoinRequest;
    
    /**
     * With this method the citizen can vote for a membership request in a positive way or negative ones.
     * 
     * @param citizen 				The voter
     * @param membershiprequest		The membership request that is subject on vote
     * @param positive				If the vote is positive or not
     */
    public void voteRequest(CitizenDTO citizen,JoinrequestDTO membershiprequest, boolean positive);
    
    /**
     * This method allow a citizen to retrieve the list of requester of a party. We shall pass to the method also the citizen that wants to see the list to check if the citizen has the right to retrieve the list.
     * @param citizen
     * @param party
     * @return  array that contains all the join request of the party
     */
    public JoinrequestDTO[] getJoinrequestFromParty(CitizenDTO citizen, PartyDTO party);
    
    public boolean canRequest(CitizenDTO Citizen);
    
    // methods for joinvote
    
	public boolean hasAlreadyJoinVoted(CitizenDTO citizen, JoinrequestDTO joinrequest);

	public void submitJoinVote(JoinVoteDTO joinvote) throws  CannotSendJoinVote;
	
	public boolean candidacyIsOpen();
	
	public int governorEndCandidacy() throws CannotSubmitMembership;

	public void createMembership(MembershipDTO membership) throws managerexception.CannotSubmitMembership;	

	public boolean canJoinVote(CitizenDTO citizen, JoinrequestDTO joinrequest);

}
